From: Marco Trevisan (Treviño) Date: Thu, 16 Apr 2026 02:33:45 +0000 (+0200) Subject: appFavorites: Only emit :changed signal on changes X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~10^2^2~35 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c5aea946fd48b2176b7e65bf92a3c0ff951678cd;p=gnome-shell.git appFavorites: Only emit :changed signal on changes We were emitting the :changed signal on every setting or app-filter change even though the actual favorites list might not have changed. So now every time it's relevant, check if something is changed before emitting the :changed signal. We do a deep check of the app IDs as potentially an app could have been removed while another is being installed during the same update window, and the length of the IDs list wouldn't change. Part-of: --- diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js index b4dec3aac..a4ec6cb30 100644 --- a/js/ui/appFavorites.js +++ b/js/ui/appFavorites.js @@ -9,20 +9,32 @@ class AppFavorites extends Signals.EventEmitter { // Filter the apps through the user’s parental controls. this._parentalControlsManager = ParentalControlsManager.getDefault(); - this._parentalControlsManager.connect('app-filter-changed', () => { - this.reload(); - this.emit('changed'); - }); + this._parentalControlsManager.connect('app-filter-changed', + () => this._updateFavorites()); this.FAVORITE_APPS_KEY = 'favorite-apps'; this._favorites = {}; - global.settings.connect(`changed::${this.FAVORITE_APPS_KEY}`, this._onFavsChanged.bind(this)); + global.settings.connect(`changed::${this.FAVORITE_APPS_KEY}`, + () => this._updateFavorites()); + this.reload(); } - _onFavsChanged() { + _updateFavorites() { + const oldIDs = this._getIds(); this.reload(); - this.emit('changed'); + const newIDs = this._getIds(); + + const haveChanged = () => { + if (oldIDs.length !== newIDs.length) + return true; + + return oldIDs.some( + (id, i) => id !== newIDs[i] || !this.isFavorite(id)); + }; + + if (haveChanged()) + this.emit('changed'); } reload() {